import commonService from 'service/common'
export default {
    //根据学生ID获取学生资料
    async getStudentById(data) {
        let dataObj = Object.assign({
            id: ''
        }, data)

        let paramsJson = {
            baseURL: '/third/',
            method: 'get',
            url: 'api/student/getStudentById',
            params: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        if (jsondata.code == 200) {
            return jsondata.data
        }
    },
    //根据家长手机号获取学生资料
    async getStudentsByMobile(data) {
        let dataObj = Object.assign({
            mobile: ''
        }, data)

        let paramsJson = {
            baseURL: '/third/',
            method: 'get',
            url: 'api/student/getStudentsByMobile',
            params: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        if (jsondata.code == 200) {
            return jsondata.data
        }
    },
    //根据familyid批量获取家长资料
    async getParentsByFamilyIds(data) {
        let dataObj = Object.assign({
            familyIds: ''
        }, data)

        let paramsJson = {
            baseURL: '/third/',
            method: 'get',
            url: 'api/parent/getParentsByFamilyIds',
            params: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        let familyList = []
        if (jsondata.code == 200) {
            familyList = jsondata.data[data.familyIds]
        }
        return familyList
    },
    //同步 根据familyid批量获取家长资料
    getSyncParentsByFamilyIds(data) {
        let dataObj = Object.assign({
            familyIds: ''
        }, data)

        let paramsJson = {
            baseURL: '/third/',
            method: 'get',
            url: 'api/parent/getParentsByFamilyIds',
            data: dataObj
        }
        return commonService.syncAjax(paramsJson)
            // let familyList = []
            // if (jsondata.code == 200) {
            //     familyList = jsondata.data[data.familyIds]
            // }
            // return familyList

    },
    //获取学生的课时账户列表
    async getCourseAccountListByStudentId(data) {
        let dataObj = Object.assign({
            studentId: '',
            fields: 'id,student_id,left_class_hour,total_class_hour,frozen_class_hour,balance_type,create_time,update_time,is_vaild'
        }, data)

        let paramsJson = {
            baseURL: '/2third/',
            method: 'get',
            url: 'api/service/courseAccount/getCourseAccountListByStudentId',
            params: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //根据studentId查询leads
    async getStudentLead(data) {
        let id = data.id

        let paramsJson = {
            baseURL: '/3third/',
            method: 'get',
            url: 'api/student/' + id + '/leads'
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata.data
    },
    //根据channelid 得到渠道信息
    async getChannelInfo(data) {
        let dataObj = Object.assign({
            id: ''
        }, data)

        let paramsJson = {
            baseURL: '/4third/',
            method: 'get',
            url: 'api/service/private/channel/find',
            params: dataObj,
            // headers: { Authorization: `management 1610471 854536a8-1f02-4e7b-bb89-1eed12da74dd` }
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata.data
    },
    //根据Id获取员工
    async getStaffInfo(data) {
        let id = data.id
        if (id < 0 || !id) {
            return ''
        }
        let paramsJson = {
            baseURL: '/5third/',
            method: 'get',
            url: 'api/staff/' + id
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //根据familyId查询学生地址
    async getStudentAdress(data) {
        let dataObj = Object.assign({
            familyId: ''
        }, data)

        let paramsJson = {
            baseURL: '/6third/',
            method: 'get',
            url: 'api/service/public/CustomerAddress/list',
            params: dataObj,
            headers: { Authorization: `management 1610471 854536a8-1f02-4e7b-bb89-1eed12da74dd` }
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //添加学生的家庭地址
    async createStudentAdress({ data, callback }) {
        let dataObj = Object.assign({
            userName: '',
            mobile: '',
            province: '',
            city: '',
            district: '',
            address: '',
            familyId: '',
            isDefault: 0 //默认地址
        }, data)

        callback = callback ? callback : function() {}
        let paramsJson = {
            baseURL: '/6third/',
            method: 'post',
            url: 'api/service/public/CustomerAddress/create',
            data: dataObj,
            callback: callback
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //修改学生的家庭地址
    async updateStudentAdress({ data, callback }) {
        let dataObj = Object.assign({
            id: '',
            userName: '',
            mobile: '',
            province: '',
            city: '',
            district: '',
            address: '',
            familyId: '',
            isDefault: 0
        }, data)
        callback = callback ? callback : function() {}

        let paramsJson = {
            baseURL: '/6third/',
            method: 'put',
            url: '/api/service/public/CustomerAddress/update',
            data: dataObj,
            callback: callback
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //删除地址
    async delStuAddress({ data, callback }) {
        let dataObj = Object.assign({
            id: ''
        }, data)
        callback = callback ? callback : function() {}

        let paramsJson = {
            baseURL: '/6third/',
            method: 'put',
            url: '/api/service/public/CustomerAddress/delete',
            params: dataObj,
            callback: callback
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //设置默认地址
    async setStuDefaultAddress({ data, callback }) {
        let dataObj = Object.assign({
            id: '',
            isDefault: 1
        }, data)
        callback = callback ? callback : function() {}

        let paramsJson = {
            baseURL: '/6third/',
            method: 'put',
            url: '/api/service/public/CustomerAddress/isDefault',
            params: dataObj,
            callback: callback
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //补差倒计时
    async findBalanceSurPlus(data) {
        let studentId = data.studentId

        let paramsJson = {
            baseURL: '/7third/',
            method: 'get',
            url: '/api/findBalanceSurPlus/' + studentId
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //查询学生的follow up
    async getStudentFollowUps(data) {
        let dataObj = Object.assign({
            studentId: '',
            start: 1, //一页的开始
            limit: 10, //一页的个数
            categoryId: '', //员工类型，1:CC，2:TMK，3:CLT，4:FIREMAN，5:中教，6:IT TEST，7:GENERAL COMMENT，8:OS，9:CS-1，10:CS-2，11:CS-38，12:NEW_TMK
            finishType: '' //结束状态： 0-忽略，1-无效跟进，2-完成跟进
        }, data)

        let paramsJson = {
            baseURL: '/7third/',
            method: 'get',
            url: '/api/followupfacade/student/followups'
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //批量获取学生的课时账户（没有用到）
    // async getCourseAccountListByStudentIdList(data) {
    //     let dataObj = Object.assign({
    //         studentIds: '',
    //         fields: 'id,student_id,left_class_hour,total_class_hour,frozen_class_hour,balance_type,create_time,update_time,is_vaild'
    //     }, data)

    //     let paramsJson = {
    //         baseURL: '/third/',
    //         method: 'get',
    //         url: 'api/service/courseAccount/getCourseAccountListByStudentIdList',
    //         params: dataObj
    //     }
    //     let jsondata = await commonService.asyncFetchData(paramsJson)
    //     return jsondata
    // },


}